package com.ruoyi.buss.home.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.buss.customer.domain.DataCustomerBankRelation;
import com.ruoyi.buss.customer.domain.DataCustomerInfo;
import com.ruoyi.buss.grid.cj.domain.DataWgWgcjVillage;
import com.ruoyi.buss.grid.sh.domain.DataWgShsurvey;
import com.ruoyi.buss.grid.sq.domain.DataWgWgsqSq;
import com.ruoyi.buss.home.service.IHomeService;
import com.ruoyi.buss.qmcy.domain.QmcyCustCksd;
import com.ruoyi.buss.qmcy.domain.QmcyCustDkmx;
import com.ruoyi.buss.qmcy.domain.QmcyCustLicaiSaleinfo;
import com.ruoyi.buss.qmcy.domain.QmcyCustPersonalInfo;
import com.ruoyi.buss.qmcy.domain.QmcyCustZhjy;
import com.ruoyi.buss.report.domain.AdvanceHk;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.RemoteUserService;
import com.ruoyi.system.api.model.LoginUser;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 首页controller
 */
@Api(tags = {"首页controller"})
@RestController
@RequestMapping("/home")
public class HomeController extends BaseController
{
    @Autowired
    private TokenService tokenService;

    @Autowired
    private IHomeService homeService;

    @Autowired
    private RemoteUserService remoteUserService;

    @ApiOperation(value = "查询大额资金变动信息", notes = "查询大额资金变动信息")
    @PreAuthorize(hasPermi = "buss:home:largeFundReminderMore")
    @GetMapping("/largeFundReminderMore")
    public TableDataInfo largeFundReminderMore()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        QmcyCustZhjy qmcyCustZhjy = new QmcyCustZhjy();

        startPage("JYJE DESC");
        List<QmcyCustZhjy> doList = homeService.largeFundReminderMore(qmcyCustZhjy,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "查询大额资金公共池变动信息公共池", notes = "查询大额资金公共池变动信息公共池")
    @PreAuthorize(hasPermi = "buss:home:largeFundReminderGgc")
    @GetMapping("/largeFundReminderGgc")
    public TableDataInfo largeFundReminderGgc()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        QmcyCustZhjy qmcyCustZhjy = new QmcyCustZhjy();

        startPage("JYJE DESC");
        List<QmcyCustZhjy> doList = homeService.largeFundReminderGgc(qmcyCustZhjy,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "贷款产品到期提醒", notes = "贷款产品到期提醒")
    @PreAuthorize(hasPermi = "buss:home:productExpireDKMore")
        @GetMapping("/productExpireDKMore")
    public TableDataInfo productExpireDKMore()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        QmcyCustDkmx qmcyCustDkmx = new QmcyCustDkmx();

        startPage("JSRQ asc");
        List<QmcyCustDkmx> doList = homeService.productExpireDKMore(qmcyCustDkmx,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "贷款产品到期提醒公共池", notes = "贷款产品到期提醒公共池")
    @PreAuthorize(hasPermi = "buss:home:productExpireDKGgc")
    @GetMapping("/productExpireDKGgc")
    public TableDataInfo productExpireDKGgc()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        QmcyCustDkmx qmcyCustDkmx = new QmcyCustDkmx();

        startPage("JSRQ asc");
        List<QmcyCustDkmx> doList = homeService.productExpireDKGgc(qmcyCustDkmx,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "理财产品到期提醒", notes = "理财产品到期提醒")
    @PreAuthorize(hasPermi = "buss:home:productExpireLcMore")
    @GetMapping("/productExpireLcMore")
    public TableDataInfo productExpireLcMore()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        QmcyCustLicaiSaleinfo qmcyCustLicaiSaleinfo = new QmcyCustLicaiSaleinfo();

        startPage("PRODEDATE asc");
        List<QmcyCustLicaiSaleinfo> doList = homeService.productExpireLcMore(qmcyCustLicaiSaleinfo,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "理财产品到期提醒公共池", notes = "理财产品到期提醒公共池")
    @PreAuthorize(hasPermi = "buss:home:productExpireLcGgc")
    @GetMapping("/productExpireLcGgc")
    public TableDataInfo productExpireLcGgc()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        QmcyCustLicaiSaleinfo qmcyCustLicaiSaleinfo = new QmcyCustLicaiSaleinfo();

        startPage("PRODEDATE asc");
        List<QmcyCustLicaiSaleinfo> doList = homeService.productExpireLcGgc(qmcyCustLicaiSaleinfo,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "存款产品到期提醒", notes = "存款产品到期提醒")
    @PreAuthorize(hasPermi = "buss:home:productExpireCkMore")
    @GetMapping("/productExpireCkMore")
    public TableDataInfo productExpireCkMore()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        QmcyCustCksd qmcyCustCksd = new QmcyCustCksd();

        startPage();
        List<QmcyCustCksd> doList = homeService.productExpireCkMore(qmcyCustCksd,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "存款产品到期提醒公共池", notes = "存款产品到期提醒公共池")
    @PreAuthorize(hasPermi = "buss:home:productExpireCkGgc")
    @GetMapping("/productExpireCkGgc")
    public TableDataInfo productExpireCkGgc()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        QmcyCustCksd qmcyCustCksd = new QmcyCustCksd();

        startPage();
        List<QmcyCustCksd> doList = homeService.productExpireCkGgc(qmcyCustCksd,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "查询客户生日提醒", notes = "查询客户生日提醒")
    @PreAuthorize(hasPermi = "buss:home:queryBirthDayTadayMore")
    @GetMapping("/queryBirthDayTadayMore")
    public TableDataInfo queryBirthDayTadayMore()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        startPage();
        List<DataCustomerInfo> doList = homeService.queryBirthDayTadayMore(userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "查询客户生日提醒公共池", notes = "查询客户生日提醒公共池")
    @PreAuthorize(hasPermi = "buss:home:queryBirthDayTadayGgc")
    @GetMapping("/queryBirthDayTadayGgc")
    public TableDataInfo queryBirthDayTadayGgc()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        startPage();
        List<DataCustomerInfo> doList = homeService.queryBirthDayTadayGgc(userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "客户贡献度升降", notes = "客户贡献度升降")
    @PreAuthorize(hasPermi = "buss:home:productExpireKhGxMore")
    @GetMapping("/productExpireKhGxMore")
    public TableDataInfo productExpireKhGxMore()
    {
        LoginUser userInfo = tokenService.getLoginUser();

        startPage("CONTRIBUTION DESC");
        List<QmcyCustPersonalInfo> doList = homeService.productExpireKhGxMore(userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "我的存款客户top10", notes = "我的存款客户top10")
    @PreAuthorize(hasPermi = "buss:home:ckTop")
    @GetMapping("/ckTop")
    public TableDataInfo ckTop(DataCustomerBankRelation dataCustomerBankRelation)
    {
        LoginUser userInfo = tokenService.getLoginUser();
        startPage();
        List<DataCustomerBankRelation> doList = homeService.ckTop(dataCustomerBankRelation,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "贷款客户top10", notes = "贷款客户top10")
    @PreAuthorize(hasPermi = "buss:home:dkTop")
    @GetMapping("/dkTop")
    public TableDataInfo dkTop(DataCustomerBankRelation dataCustomerBankRelation)
    {
        LoginUser userInfo = tokenService.getLoginUser();
        startPage();
        List<DataCustomerBankRelation> doList = homeService.dkTop(dataCustomerBankRelation,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "资金流出top10", notes = "资金流出top10")
    @PreAuthorize(hasPermi = "buss:home:zjlcTop")
    @GetMapping("/zjlcTop")
    public TableDataInfo zjlcTop(QmcyCustZhjy qmcyCustZhjy)
    {
        LoginUser userInfo = tokenService.getLoginUser();
        startPage();
        List<QmcyCustZhjy> doList = homeService.zjlcTop(qmcyCustZhjy,userInfo);

        return getDataTable(doList);
    }

    @ApiOperation(value = "首页客户等级饼图", notes = "首页客户等级饼图")
    @PreAuthorize(hasPermi = "buss:home:bt")
    @GetMapping("/bt")
    public AjaxResult bt()
    {
        List<Map<String,Object>> list = homeService.bt();

        return AjaxResult.success(list);
    }

    /**
     * 首页营销业绩走势图
     * @return
     */
    @ApiOperation(value = "首页营销业绩走势图", notes = "首页营销业绩走势图")
    @PreAuthorize(hasPermi = "buss:home:zhqst")
    @GetMapping("/zhqst")
    public AjaxResult zhqst(QmcyCustPersonalInfo qmcyCustPersonalInfo)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        List<QmcyCustPersonalInfo> list = homeService.zhqst(qmcyCustPersonalInfo,userInfo);

        return AjaxResult.success(list);
    }

    /**
     * 首页网格商户概况趋势图
     * @return
     */
    @ApiOperation(value = "首页网格商户概况趋势图", notes = "首页网格商户概况趋势图")
    @PreAuthorize(hasPermi = "buss:home:getWgshSurveyList")
    @GetMapping("/getWgshSurveyList")
    public AjaxResult getWgshSurveyList(DataWgShsurvey dataWgShsurvey)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        List<DataWgShsurvey> list = homeService.getWgshSurveyList(dataWgShsurvey,userInfo);

        return AjaxResult.success(list);
    }

    /**
     * 首页网格村居趋势图
     * @return
     */
    @ApiOperation(value = "首页网格村居概况趋势图", notes = "首页网格村居概况趋势图")
    @PreAuthorize(hasPermi = "buss:home:getWgcjSurveyList")
    @GetMapping("/getWgcjSurveyList")
    public AjaxResult getWgcjSurveyList(DataWgWgcjVillage dataWgWgcjVillage)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        List<DataWgWgcjVillage> list = homeService.getWgcjSurveyList(dataWgWgcjVillage,userInfo);

        return AjaxResult.success(list);
    }

    /**
     * 首页网格社区趋势图
     * @return
     */
    @ApiOperation(value = "首页网格社区趋势图", notes = "首页网格社区趋势图")
    @PreAuthorize(hasPermi = "buss:home:getWgsqSurveyList")
    @GetMapping("/getWgsqSurveyList")
    public AjaxResult getWgsqSurveyList(DataWgWgsqSq dataWgWgsqSq)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        List<DataWgWgsqSq> list = homeService.getWgsqSurveyList(dataWgWgsqSq,userInfo);

        return AjaxResult.success(list);
    }

    /**
     * 星级客户分布(是否对公  1对公 0对私)
     * @return
     */
    @ApiOperation(value = "星级客户分布", notes = "星级客户分布")
    @PreAuthorize(hasPermi = "buss:home:xjkhProportionDgds")
    @GetMapping("/xjkhProportionDgds")
    public AjaxResult xjkhProportionDgds(@RequestParam("dgds") String dgds)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        Map<String,String> list = homeService.xjkhProportionDgds(dgds,userInfo);

        return AjaxResult.success(list);
    }
    @ApiOperation(value = "查询有提前一个月还款大于等于十万意向的客户信息", notes = "查询有提前一个月还款大于等于十万意向的客户信息")
    @PreAuthorize(hasPermi = "buss:home:getAdvanceHkMore")
    @GetMapping("/getAdvanceHkMore")
    public TableDataInfo getAdvanceHkMore()
    {
        LoginUser userInfo = tokenService.getLoginUser();
        startPage("CRJE DESC");
        List<AdvanceHk> doList = homeService.getAdvanceHkMore(userInfo);

        return getDataTable(doList);
    }
    
}
